package com.chuangke.mds.service;

import java.text.ParseException;
import java.util.List;

import com.chuangke.file.model.FileInfo;
import com.chuangke.mds.entity.KnowledgeVersion;
import org.springframework.scheduling.annotation.Async;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chuangke.common.db.page.CkPageQuery;
import com.chuangke.framework.service.BatchOrderFlowService;
import com.chuangke.mds.entity.Knowledge;

public interface KnowledgeService extends BatchOrderFlowService{

    /**
     * 上传
     * @param knowledgeId 知识Id
     * @param file
     */
    FileInfo upload(String knowledgeId, MultipartFile file) ;

    /**
     * 保存
     * @param knowledge
     */
    String save(Knowledge knowledge) throws ParseException;

    /**
     * 删除
     * @param idList 知识id
     */
    void delete(List<String> idList);

    /**
     * 删除附件
     * @param idList KnowledgeAffix.id
     */
    void deleteAffix(List<String> idList);

    /**
     * 加载
     * @param id 知识id
     * @return
     */
    Knowledge load(String id);

    /**
     * 分页查询
     * @param page
     * @return
     */
    IPage<Knowledge> page(CkPageQuery page);

    /**
     * 查询知识及其附件内容列表
     * @return
     */
    List<Knowledge> getKnowledgeList();

    IPage<KnowledgeVersion> pageVersion(CkPageQuery  page);

    KnowledgeVersion loadVersion(String id);

    List<Knowledge> getHomePagePopularData(CkPageQuery page);

    List<Knowledge> getHomePageLatestData(CkPageQuery page);

    @Async
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    void asyncIncrementReadingCount(String id);
}
